package org.example.demos.web;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class SecondConsumer {
    @RabbitListener(queues = "test1")
    public void receive(String message) {
        System.out.println("SecondConsumer received message: " + message);
    }
    @RabbitListener(queues = "work.queue")
    public void receive1(String message) {
        System.out.println("SecondConsumer received message1111111111: " + message);
    }
    @RabbitListener(queues = "work.queue")
    public void receive2(String message) {
        System.out.println("SecondConsumer received message2222222222: " + message);
    }
    @RabbitListener(queues = "fanout.queue1")
    public void receive3(String message) {
        System.out.println("fanout.queue1 received message2222222222: " + message);
    }
    @RabbitListener(queues = "fanout.queue2")
    public void receive4(String message) {
        System.out.println("fanout.queue2 received message2222222222: " + message);
    }
    @RabbitListener(queues = "topic.queue1")
    public void receive5(String message) {
        System.out.println("topic.queue1 received message2222222222: " + message);
    }
    @RabbitListener(queues = "topic.queue2")
    public void receive6(String message) {
        System.out.println("topic.queue2 received message2222222222: " + message);
    }
    @RabbitListener(queues = "fanout.queue3")
    public void receive7(String message) {
        System.out.println("fanout.queue3 received message2222222222: " + message);
    }
    @RabbitListener(queues = "direct.queue1")
    public void receive8(String message) {
        System.out.println("fanout.queue3 received message2222222222: " + message);
    }
    @RabbitListener(queues = "direct.queue2")
    public void receive9(String message) {
        System.out.println("fanout.queue3 received message2222222222: " + message);
    }
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "test2"),
  exchange = @Exchange(name = "mirror.test", type = ExchangeTypes.TOPIC), key = "test2.#"))
    public void receive10(String message) {
        System.out.println("test2 received message2222222222: " + message);
    }
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "test3"),
            exchange = @Exchange(name = "mirror.test", type = ExchangeTypes.TOPIC), key = "#.news"))
    public void receive11(String message) {
        System.out.println("test3 received message2222222222: " + message);
    }
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "test4"),
            exchange = @Exchange(name = "mirror.test", type = ExchangeTypes.TOPIC), key = "q"))
    public void receive12(Map message) {
        System.out.println("test3 received message2222222222: " + message);
    }


}
